package arithmetic.encrypt.rsa;

import java.io.IOException;
import java.util.Map;
import java.util.TreeMap;

/**
 * @Auther: luobiao
 * @Description:
 * 生成私钥
 * openssl genrsa -out rsa_private_key.pem 1024
 * 生成公钥
 * openssl rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem
 * 转换私钥编码
 * openssl pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt
 *
 * 通过私钥对messages进行签名
 * openssl dgst -md5 -out messages.sign -sign pkcs8_rsa_private_key.pem messages
 * 通过公钥验证签名
 * openssl dgst -md5 -verify rsa_public_key.pem -signature messages.sign messages
 */
public class Test {
    public static void main(String[] args) throws IOException {
        Map map=new TreeMap();
        map.put("name", "luobiao");
        map.put("cardNo", "360313199104043015");
        map.put("prodId", "TC2_TWOVALID");
        map.put("requestTime", "2021-01-30 17:23:56");
        map.put("requestNo", "dgfdfQdfg123456789001");
        //map.put("sign", "name");
        map.put("token", "ioxp1Pcy85kEM2tn");

        StringBuffer sb = new StringBuffer();
        map.forEach((k,v)->{
            sb.append(k + "=" + v + "&");
        });
        sb.deleteCharAt(sb.length()-1);
        System.out.println(sb);

    }

}
